home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 November: Tool Chest / Dev.CD Nov 00 TC Disk 1.toast / Sample Code / Games / SprocketInvaders / Source / ErrorHandler.c < prev    next >
Encoding:
Text File  |  2000-09-28  |  3.3 KB  |  132 lines  |  [TEXT/MPS ]

  1. /*
  2.     File:        ErrorHandler.c
  3.  
  4.     Contains:    xxx put contents here xxx
  5.  
  6.     Version:    xxx put version here xxx
  7.  
  8.     Copyright:    © 1998-1999 by Apple Computer, Inc., all rights reserved.
  9.  
  10.     File Ownership:
  11.  
  12.         DRI:                xxx put dri here xxx
  13.  
  14.         Other Contact:        xxx put other contact here xxx
  15.  
  16.         Technology:            xxx put technology here xxx
  17.  
  18.     Writers:
  19.  
  20.         (cjd)    Chris De Salvo
  21.         (sjb)    Steve Bollinger
  22.         (BWS)    Brent Schorsch
  23.  
  24.     Change History (most recent first):
  25.  
  26.       <SP10>     1/21/99    cjd        Make sure that ISpSuspend is defined before calling it
  27.          <9>     6/18/98    sjb        InputSprocket.h comes from <> place
  28.          <8>     6/12/98    BWS        Now uses InputSprocket 68k
  29. */
  30.  
  31. //•    ------------------------------------------------------------------------------------------    •
  32. //•
  33. //•    Copyright © 1996 Apple Computer, Inc., All Rights Reserved
  34. //•
  35. //•
  36. //•        You may incorporate this sample code into your applications without
  37. //•        restriction, though the sample code has been provided "AS IS" and the
  38. //•        responsibility for its operation is 100% yours.  However, what you are
  39. //•        not permitted to do is to redistribute the source as "DSC Sample Code"
  40. //•        after having made changes. If you're going to re-distribute the source,
  41. //•        we require that you make it clear in the source that the code was
  42. //•        descended from Apple Sample Code, but that you've made changes.
  43. //•
  44. //•        Authors:
  45. //•            Chris De Salvo
  46. //•
  47. //•    ------------------------------------------------------------------------------------------    •
  48.  
  49. //•    ------------------------------    Includes
  50.  
  51. #include <Dialogs.h>
  52. #include <Processes.h>
  53. #include <TextUtils.h>
  54.  
  55. #include <string.h>
  56.  
  57. #include <InputSprocket.h>
  58.  
  59. #include "ErrorHandler.h"
  60. #include "SIResources.h"
  61.  
  62. //•    ------------------------------    Private Definitions
  63. //•    ------------------------------    Private Constants
  64. //•    ------------------------------    Private Types
  65. //•    ------------------------------    Private Structs
  66. //•    ------------------------------    Private Variables
  67. //•    ------------------------------    Private Functions
  68. //•    ------------------------------    Public Variables
  69.  
  70. //•    ------------------------------    FatalError
  71.  
  72. void
  73. FatalError(char *error)
  74. {
  75. Str255    errorHeader;
  76. UInt8    errorString[256];
  77.  
  78.     strcpy((char *) errorString + 1, error);
  79.     errorString[0] = strlen((char *) errorString + 1);
  80.     GetIndString(errorHeader, kSTRMessageStrings, kSTRiFatal);
  81.  
  82.     if (nil != ISpSuspend)
  83.         ISpSuspend();
  84.     
  85.     ParamText(errorHeader, errorString, "\p", "\p");
  86.     if (Alert(kALRTFatal, nil) == cancel)
  87.         Debugger();
  88.     
  89.     ExitToShell();
  90. }
  91.  
  92. //•    ------------------------------    NonFatalError
  93.  
  94. void
  95. NonFatalError(char *error)
  96. {
  97. Str255    errorHeader;
  98. UInt8    errorString[256];
  99.  
  100.     strcpy((char *) errorString + 1, error);
  101.     errorString[0] = strlen((char *) errorString + 1);
  102.     GetIndString(errorHeader, kSTRMessageStrings, kSTRiNonFatal);
  103.  
  104.     if (nil != ISpSuspend)
  105.         ISpSuspend();
  106.     
  107.     ParamText(errorHeader, errorString, "\p", "\p");
  108.     Alert(kALRTNonFatal, nil);
  109. }
  110.  
  111. //•    ------------------------------    MessageError
  112.  
  113. short
  114. MessageError(char *error1, char *error2)
  115. {
  116. UInt8    errorString1[256];
  117. UInt8    errorString2[256];
  118.  
  119.     strcpy((char *) errorString1 + 1, error1);
  120.     errorString1[0] = strlen((char *) errorString1 + 1);
  121.  
  122.     strcpy((char *) errorString2 + 1, error2);
  123.     errorString2[0] = strlen((char *) errorString2 + 1);
  124.  
  125.     if (nil != ISpSuspend)
  126.         ISpSuspend();
  127.     
  128.     ParamText(errorString1, errorString2, "\p", "\p");
  129.  
  130.     return (Alert(kALRTMessage, nil));
  131. }
  132.